]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
notificationDaemon: Work around JS interpreter bug
authorColin Walters <walters@verbum.org>
Thu, 25 Aug 2011 13:20:00 +0000 (09:20 -0400)
committerColin Walters <walters@verbum.org>
Thu, 25 Aug 2011 13:20:00 +0000 (09:20 -0400)
The "id" variable was being sporadically reset to null, and as far as
Florian and I could determine, this is actually a Spidermonkey bug.

The issue has something to do with:

1) use of "let" for the variable
2) Nesting a dynamic closure inside of a for() loop

Work around it here for now - I tried to create a minimized test case
to hand to the Spidermonkey developers, but failed.  A big part of
the problem is it's only sporadically reproducible.

js/ui/notificationDaemon.js

index 86bd4a27b82b9835ccd3afdbf47cff9facc96c99..915808fcb13ba03437ebdbecb3b30106bdd8a7e4 100644 (file)
@@ -305,7 +305,7 @@ NotificationDaemon.prototype = {
             ndata.notification = notification;
             notification.connect('destroy', Lang.bind(this,
                 function(n, reason) {
-                    delete this._notifications[id];
+                    delete this._notifications[ndata.id];
                     let notificationClosedReason;
                     switch (reason) {
                         case MessageTray.NotificationDestroyedReason.EXPIRED:
@@ -318,11 +318,11 @@ NotificationDaemon.prototype = {
                             notificationClosedReason = NotificationClosedReason.APP_CLOSED;
                             break;
                     }
-                    this._emitNotificationClosed(id, notificationClosedReason);
+                    this._emitNotificationClosed(ndata.id, notificationClosedReason);
                 }));
             notification.connect('action-invoked', Lang.bind(this,
                 function(n, actionId) {
-                    this._emitActionInvoked(id, actionId);
+                    this._emitActionInvoked(ndata.id, actionId);
                 }));
         } else {
             notification.update(summary, body, { icon: iconActor,
@@ -336,7 +336,7 @@ NotificationDaemon.prototype = {
                 if (actions[i] == 'default')
                     notification.connect('clicked', Lang.bind(this,
                         function() {
-                            this._emitActionInvoked(id, "default");
+                            this._emitActionInvoked(ndata.id, "default");
                         }));
                 else
                     notification.addButton(actions[i], actions[i + 1]);